package com.abing.starry.controller;

import com.abing.starry.model.request.question.SubmitRecordRequest;
import com.abing.starry.model.vo.question.QuestionSubmitVO;
import com.abing.starry.service.QuestionSubmitService;
import com.abing.starry.spi.quote.FamousQuoteManager;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Author CaptainBing
 * @Date 2024/9/6 10:42
 * @Description
 */
@RestController
@RequestMapping("/question/submit")
@RequiredArgsConstructor
public class QuestionSubmitController {

    private final QuestionSubmitService questionSubmitService;

    private final FamousQuoteManager famousQuoteManager;

    @PostMapping("/page")
    @Operation(summary = "分页查询提交记录")
    public IPage<QuestionSubmitVO> listQuestionSubmitByPage(@RequestBody SubmitRecordRequest submitRecordRequest) {
        return questionSubmitService.listQuestionSubmitByPage(submitRecordRequest);
    }

    @GetMapping("/famous")
    @Operation(summary = "随机返回一句名人名言")
    public String randomFamousQuotes() {
        return famousQuoteManager.getRandomQuote();
    }

}
